// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/accesscontrol/api/AccessRecordApi'

import ComClass from '@api/ComQuery'

import ListClass from '@api/accesscontrol/model/AccessRecordDto'
import InOutClass from '@api/accesscontrol/model/AccessStatisticReq'

const TypeClass = InOutClass
const TopClass = InOutClass

const CLIENT = CORE.grpcCLIENT(Client)
const COM = [ComClass, 'comQuery']

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 列表 —————————————————————————————— //

  async getList(param, TIP = '[门禁管理] 查询通行记录') {
    const DTO = CORE.grpcDTO(ListClass, param, COM)
    const { comQuery, content } = await CORE.grpc(TIP, CLIENT, 'accessRecordQuery', DTO)
    return [comQuery.totalCount, content]
  },

  // —————————————————————————————— 进出统计 —————————————————————————————— //

  async getInOut(param, TIP = '[门禁管理] 查询进出统计') {
    const DTO = CORE.grpcDTO(InOutClass, param)
    const { content } = await CORE.grpc(TIP, CLIENT, 'enterExitStatistic', DTO)
    return content
  },

  // —————————————————————————————— 通行统计 —————————————————————————————— //

  async getType(param, TIP = '[门禁管理] 查询通行统计') {
    const DTO = CORE.grpcDTO(TypeClass, param)
    const { content2 } = await CORE.grpc(TIP, CLIENT, 'accessTypeStatistic', DTO)
    return content2
  },

  // —————————————————————————————— 通行TOP5 —————————————————————————————— //

  async getTop(param, TIP = '[门禁管理] 查询通行TOP5') {
    const DTO = CORE.grpcDTO(TopClass, param)
    const { content } = await CORE.grpc(TIP, CLIENT, 'accessRankStatistic', DTO)
    return content
  },
}
